package com.xzlf.task;

import com.xzlf.domain.JobTask;
import com.xzlf.service.JobTaskService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@Data
@Slf4j
//@Component
//@EnableScheduling
public class TestStaticTask {

    @Autowired
    private JobTaskService jobTaskService;

    @Autowired
    private Map<String, JobTask> jobTaskMap;

    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

//    @Scheduled(cron = "0/5 * * * * ?")
//    @Scheduled(cron = "#{jobTaskConfig.jobTaskMap.get(\"PrintTask\").getJobCron()}")
    @Scheduled(cron = "#{jobTaskMap.get(\"PrintTask\").getJobCron()}")
    public void printTask(){
        log.info("打印任务：{}", simpleDateFormat.format(new Date()));
    }
}
